package com.x.mvp.widget.ruler;

import android.graphics.Canvas;
import android.graphics.Color;

/**
 * Created by H on 18/3/5.
 */

public abstract class Rander {
    protected int foregoundColor = Color.BLUE;
    protected int backgoundColor = Color.BLACK;
    protected int split;
    protected int totalLength;
    protected int offset;


    public Rander(int foregoundColor, int backgoundColor, int split, int totalLength, int offset) {
        this.foregoundColor = foregoundColor;
        this.backgoundColor = backgoundColor;
        this.split = split;
        this.totalLength = totalLength;
        this.offset = offset;
        init();
    }

    void init() {

    }

    public void setOffset(int offset) {
        this.offset = offset;
    }

    public abstract void onDraw(Canvas canvas);

    protected int[] getFirstScale(int w) {
        int[] ret = new int[2];
        int start = totalLength - offset;
        int count = offset / split;
        int mod = offset % split;
        ret[0] = mod;
        if (mod != 0) {
            ret[1] = count % 10 + 1;
        } else {
            ret[1] = count % 10;
        }
        return ret;
    }

}
